package com.hainatong.jcmvvmbase.mainhome.fragment;

import java.util.ArrayList;
import java.util.List;

import android.view.ViewGroup;
import com.blankj.utilcode.util.ToastUtils;
import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentListViewBinding;
import com.hainatong.jcmvvmbase.mainhome.adapter.FileItemAdapter;
import com.hainatong.jcmvvmbase.mainhome.entity.FunctionEntity;
import com.hainatong.mvvmbase.base.NoViewModel;

import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;

public class QSHEMgrFragment extends MvvmLazyFragment<FragmentListViewBinding, NoViewModel>
{

    private FileItemAdapter adapter;

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_list_view;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {

    }

    @Override
    protected void initView(View view)
    {
        adapter = new FileItemAdapter();
        View header = getLayoutInflater().inflate(R.layout.driver_dp10 , (ViewGroup) viewDataBinding.recyclerview.getParent(),false);
        adapter.addHeaderView(header);
        viewDataBinding.recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        viewDataBinding.recyclerview.setHasFixedSize(true);
        viewDataBinding.recyclerview.setAdapter(adapter);
        List<FunctionEntity> funList = new ArrayList<>();
        funList.add(new FunctionEntity(getString(R.string.smis_table),""+Constants.FUN_SMIS,0));
        funList.add(new FunctionEntity(getString(R.string.program_tips),""+Constants.FUN_PROGRAM_TIPS,0));
        funList.add(new FunctionEntity(getString(R.string.manager_notes),""+Constants.FUN_MGR_NOTES,0));
        funList.add(new FunctionEntity(getString(R.string.ship_notes),""+ Constants.FUN_SHIP_NOTES,0));
        funList.add(new FunctionEntity(getString(R.string.emergency_paln),""+Constants.FUN_EMER_PLAN,0));
        funList.add(new FunctionEntity(getString(R.string.worker_notes),""+Constants.FUN_WORKER_NOTES,0));
        funList.add(new FunctionEntity(getString(R.string.elec_mgr_table),""+Constants.FUN_MGR_TABLE,0));
        adapter.setList( funList );
        adapter.setOnItemClickListener((adapter1, view1, position) -> {

            switch ( Integer.parseInt( adapter.getItem(position).getContentTag() ) )
            {
                case Constants.FUN_SMIS:

                    break;
                case Constants.FUN_PROGRAM_TIPS:

                    break;
                case Constants.FUN_MGR_NOTES:

                    break;
                case Constants.FUN_SHIP_NOTES:

                    break;
            }
            ToastUtils.showShort( adapter.getItem(position).getTitle() );

        });
    }

}
